/**
 * @file       CKeyboardListener_test.cpp
 * @brief      TODO
 * @author     Huabo Zheng
 * @date       Jan 13, 2012
 * @Copyright  2012, www.netgear.com Inc. All rights reserved.
 */

#include "KeyboardListener.h"
#include "gtest/gtest.h"
#include "errorcode.h"
#include "MockEvent.h"
#include "MockKeyboardEvent.h"
#include "MockKeyboardListener.h"
namespace NS_LCD_AFW
{
class CKeyboardListener_test : public ::testing::Test
{
public:
	virtual void SetUp()
	{
	}
	virtual void TearDown()
	{
	}
};
TEST_F(CKeyboardListener_test,test_defualtConstruction)
{

}
TEST_F(CKeyboardListener_test,test_actionPerformed)
{
	CEventHandler *pHandler = new CEventHandler();
	CMockKeyboardListener *pListener = new CMockKeyboardListener();
	IEvent *pEvent = new CMockKeyboardEvent();
	EXPECT_EQ(NULL, pListener->getEventHandler());

	EXPECT_EQ(ERR_INVALID_EVENTHANDLER, pListener->actionPerformed(pEvent));

	pListener->setEventHandler(pHandler);
	EXPECT_EQ(ERR_INVALID_EVENT, pListener->actionPerformed(NULL));

	EXPECT_EQ(ERR_INVALID_EVENTHANDLER, pListener->actionPerformed(pEvent));

	CMockEvent *pMockEvent = new CMockEvent();
	EXPECT_EQ(ERR_NOT_KEYBOARD_EVENT, pListener->actionPerformed(pMockEvent));

	OBJ_DESTORY(pListener);
	OBJ_DELETE(pHandler);
	OBJ_DESTORY(pEvent);
	OBJ_DESTORY(pMockEvent);
}
} /* namespace NS_LCD_AFW */
